/*
 * @Author: liuying 247220246@qq.com
 * @Date: 2025-04-11 11:47:33
 * @LastEditors: liuying 247220246@qq.com
 * @LastEditTime: 2025-04-15 10:31:01
 * @FilePath: \my-book-react\src\stores\createTempSlice.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
export const createTempSlice = <T>(name: string, initialState: T, key?: string) => {
  const slice = createSlice({
    name: `${name}.${key}`,
    initialState,
    reducers: {
      set: (_, action: PayloadAction<T>) => action.payload,
    },
  });
  return { set: slice.actions.set, reducer: slice.reducer };
};
